package com.google.code.jcooky.rpc.utils;

import net.sf.json.JSONObject;

public class JsonUtils {
	public static Object getObjectFromJSON(Class<?> type, Object val) {
		if (type.equals(String.class) || type.equals(Integer.class) || type.equals(Character.class) || type.equals(Float.class)
				|| type.equals(Double.class) || type.equals(Short.class))
			return val;
		else if (val instanceof JSONObject)
			return JSONObject.toBean((JSONObject) val, type);
		
		return null;
	}
}
